---
title: Jina Embedder
sidebarTitle: Jina
---

The `JinaEmbedder` class is used to embed text data into vectors using the Jina AI API. You can get started with Jina AI [here](https://jina.ai/embeddings/).

Get your [API key](https://jina.ai/embeddings/).

## Usage

```python jina_embedder.py
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector
from agno.knowledge.embedder.jina import JinaEmbedder

# Add embedding to database
embeddings = JinaEmbedder(id="jina-embeddings-v3").get_embedding("The quick brown fox jumps over the lazy dog.")
# Print the embeddings and their dimensions
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")

# Use an embedder in a knowledge base
knowledge = Knowledge(
    vector_db=PgVector(
        db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
        table_name="jina_embeddings",
        embedder=JinaEmbedder(id="jina-embeddings-v3"),
    ),
    max_results=2,
)
```

## Advanced Usage

```python
# Configure embedder with custom settings
embedder = JinaEmbedder(
    id="jina-embeddings-v3",
    dimensions=1024,
    embedding_type="float",
    late_chunking=True,
    batch_size=50,
    timeout=30.0
)

# Use async methods for better performance
import asyncio

async def embed_texts():
    embedder = JinaEmbedder()
    texts = ["First text", "Second text", "Third text"]
    
    # Get embeddings in batches
    embeddings, usage = await embedder.async_get_embeddings_batch_and_usage(texts)
    print(f"Generated {len(embeddings)} embeddings")
    print(f"Usage info: {usage[0]}")

# Run async example
asyncio.run(embed_texts())
```

## Params

| Parameter        | Type                               | Default                | Description                                                                |
| ---------------- | ---------------------------------- | ---------------------- | -------------------------------------------------------------------------- |
| `id`             | `str`                              | `"jina-embeddings-v3"` | The model ID to use for generating embeddings.                            |
| `dimensions`     | `int`                              | `1024`                 | The number of dimensions for the embedding vectors.                       |
| `embedding_type` | `Literal["float", "base64", "int8"]` | `"float"`            | The format type of the returned embeddings.                               |
| `late_chunking`  | `bool`                             | `False`                | Whether to enable late chunking optimization.                             |
| `user`           | `Optional[str]`                    | `None`                 | User identifier for tracking purposes. Optional.                          |
| `api_key`        | `Optional[str]`                    | `JINA_API_KEY` env var | The Jina AI API key. Can be set via environment variable.                 |
| `base_url`       | `str`                              | `"https://api.jina.ai/v1/embeddings"` | The base URL for the Jina API.                      |
| `headers`        | `Optional[Dict[str, str]]`         | `None`                 | Additional headers to include in API requests. Optional.                  |
| `request_params` | `Optional[Dict[str, Any]]`         | `None`                 | Additional parameters to include in the API request. Optional.            |
| `timeout`        | `Optional[float]`                  | `None`                 | Timeout in seconds for API requests. Optional.                            |
| `enable_batch`            | `bool`                        | `False`                    | Enable batch processing to reduce API calls and avoid rate limits                |
| `batch_size`              | `int`                         | `100`                      | Number of texts to process in each API call for batch operations.                |

## Features

- **Async Support**: Full async/await support for better performance in concurrent applications
- **Batch Processing**: Efficient batch processing of multiple texts with configurable batch size
- **Late Chunking**: Support for Jina's late chunking optimization technique
- **Flexible Output**: Multiple embedding formats (float, base64, int8)
- **Usage Tracking**: Get detailed usage information for API calls
- **Error Handling**: Robust error handling with fallback mechanisms

## Developer Resources
- View [Cookbook](https://github.com/agno-agi/agno/tree/main/cookbook/knowledge/embedders/jina_embedder.py)
- [Jina AI Documentation](https://jina.ai/embeddings/)
